package cn.ml.gaoJi.api.isBlank;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class IsBlankTest {
    public static void main(String[] args) {
        BigDecimal nn = new BigDecimal(5);
        BigDecimal mm = new BigDecimal(5);
        System.out.println(nn.compareTo(mm));

        String a = null;
        String b = "";
        List list1 = new ArrayList();
        List list2 = null;
//        list.add(1);
//        list.add(2);
//        list.add(3);
//        list.add(4);
        boolean empty = list1.isEmpty();
        System.out.println("list1是否为空："+empty);
        boolean empty2 = list2.isEmpty();
        System.out.println("list2是否为空："+empty2);

        //boolean isEmpty = a.isEmpty();
        //System.out.println("a  Empty:"+ isEmpty);
        boolean isBlank1 = IsBlankTest.isBlank(a);
        System.out.println("a  isBlank:"+ isBlank1);
        boolean isBlank2 = IsBlankTest.isBlank(b);
        System.out.println("b  isBlank:"+ isBlank2);

    }

    public static Boolean isBlank(CharSequence cs) {
        int strLen = length(cs);
        if (strLen == 0) {
            return true;
        } else {
            for (int i = 0; i < strLen; ++i ) {
                if (!Character.isWhitespace(cs.charAt(i))) {
                    return false;
                }
            }
            return true;
        }

    }

    public static int length(CharSequence cs) {
        return cs == null ? 0 : cs.length();
    }

}
